import { makeAutoObservable } from 'mobx'
import { getLangByUrl, getItem } from '@/util'

const phoneWidthLine = 770 //手机宽度临界点
const ipadWidthLine = 1230 //ipad宽度临界点
class Store {
  bodyWidth = window.innerWidth //浏览器宽度
  bodyHeight = window.innerHeight //浏览器高度
  get isDeskPlatform() {
    //是否pc平台
    return this.bodyWidth > ipadWidthLine
  }
  get isPadPlatform() {
    //是否pad平台
    return (this.bodyWidth <= ipadWidthLine && this.bodyWidth > phoneWidthLine) || /(iPad|iPod|iOS)/i.test(navigator.userAgent)
  }
  get isMobilePlatform() {
    //是否手机平台
    return this.bodyWidth <= phoneWidthLine || /(iPhone|Android)/i.test(navigator.userAgent)
  }
  locale = getLangByUrl() //当前语言
  token = '' //用户token信息
  uid = '' //用户uid
  isPageTabShow = true //当前网站是否在前台(不在隐藏的tab中)
  theme = getItem('theme') ? getItem('theme') : 'dark' //light dark
  SwapUList = []
  SwapCList = []
  SwapBList = []
  SwapList = []
  SpotList = []
  get allList() {
    return []
  }
  constructor() {
    makeAutoObservable(this)
  }
}

const IndexStore = new Store()
export default IndexStore
